using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using DotNet.Utilities;
using WPFPractice.Models;
using WPFPractice.Utils;
using WPFPractice.ViewModels;

namespace WPFPractice.Windows
{
	/// <summary>
	/// WinConverters.xaml 的交互逻辑
	/// </summary>
	public partial class WinConverters : Window
	{
		public WinConverters()
		{
			InitializeComponent();
			DataContext = new ConvertersViewModel();
		}
	}
}

namespace WPFPractice.ViewModels
{
	public class ConvertersViewModel : MyViewModelBase
	{
		#region 绑定

		/// <summary>
		/// 测试数据
		/// </summary>
		public ObservableCollection<User> Datas { get; set; }

		public User SingleUser { get; set; }

		public int IntValue { get; set; }

		public List<EditTypeEnum> EditTypeEnumList { get; set; }

		public EditTypeEnum SelectedEditType { get; set; }

		public string InputText { get; set; }

		/// <summary>
		/// 参考值（数据）最小值
		/// </summary>
		public string RefValueMin { get; set; } = "0";

		/// <summary>
		/// 参考值（数据）最大值
		/// </summary>
		public string RefValueMax { get; set; } = "888";

		/// <summary>
		/// 实际值（UI）最小值
		/// </summary>
		public string RealValueMin { get; set; } = "0";

		/// <summary>
		/// 实际值（UI）最大值
		/// </summary>
		public string RealValueMax { get; set; } = "100";

		/// <summary>
		/// 绑定值
		/// </summary>
		public string BindValue { get; set; } = "120";

		#endregion

		#region 方法

		protected override void InitDataAfterConstruction()
		{
			Console.WriteLine($"演示：[多值转换器] 判断列表是否包含元素并返回指定值");
			Console.WriteLine($"演示：[转换器] 绑定内容的字符串形式作为 Key 在参数中查找 Value 字符串（参数以 | 分组，组内以 , 或 : 分隔出 key 和 value）");

			Datas = TestDataHelper.GetUsers();
			SingleUser = new User()
			{
				UserName = "单身贵族"
			};

			EditTypeEnumList = EnumExtension.GetEnumList<EditTypeEnum>();
		}

		#endregion
	}
}
